using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class Unit_Base : MonoBehaviour
{
    public enum UnitType
    {
        Charactor,
        Goods,
        CarFloor,
    }
    public abstract UnitType unitType { get; }

    public List<Unit_Base> innerUnits = new List<Unit_Base>();
     
    protected virtual void OnUnitTriggerEnter(Unit_Base unit_Base)
    {
        if (!innerUnits.Contains(unit_Base))
        {
            innerUnits.Add(unit_Base);
        }
    }
    protected virtual void OnUnitTriggerExit(Unit_Base unit_Base)
    {
        if (innerUnits.Contains(unit_Base))
        {
            innerUnits.Remove(unit_Base);
        }
    }
    protected virtual void OnTriggerEnter2D(Collider2D collision)
    {
        Unit_Base unit_Ctrl = collision.GetComponent<Unit_Base>();
        if (unit_Ctrl != null)
        {
            OnUnitTriggerEnter(unit_Ctrl);
        }
    }
    protected virtual void OnTriggerExit2D(Collider2D collision)
    {
        Unit_Base unit_Ctrl = collision.GetComponent<Unit_Base>();
        if (unit_Ctrl != null)
        {
            OnUnitTriggerExit(unit_Ctrl);
        }
    }
}
